//首页
function index() {
    let mockData = Mock.mock({
        "bannerLeftNavList": [{
            "icon": "icon-index_top_ding",
            "title": "找订单",
            "navlist|10-15": [{
                "text": "@ctitle(2,4)",
                "href": "#"
            }]
        }, {
            "icon": "icon-index_top_mian",
            "title": "面料采购",
            "navlist|8-12": [{
                "text": "@ctitle(2,4)",
                "href": "#"
            }]
        }, {
            "icon": "icon-index_top_fu",
            "title": "辅料采购",
            //公告
            //  "noticeNav":{
            //      "noticelist|5": [{
            //          "title": "@ctitle(8,10)",
            //          "text": "@ctitle(10,18)",
            //          "href": "#"
            //      }]
            //  },
            "navlist|8-12": [{
                "text": "@ctitle(2,4)",
                "href": "#"
            }]
        }],
        "bannerlist|6": [{
            "picUrl": "@image(750x485,@color)",
            "href": "#"
        }],
        "userHead": "@image(50x50,@color)",
        "userName": "@ctitle(4,5)",
        "noticeNav|5": [{
            "text": "@ctitle(10,18)",
            "href": "#"
        }],
        //聚订单
        "jdingdan": {
            "banner": "@image(240x338,@color)",
            "total": "1,668,964",
            "bannerlist|6": [{
                "href": "#",
                "banner": "@image(110x110,@color)",
                "title": "@ctitle(8,10)",
                "position": "广东 深圳市",
                "num|1000-2000": 1,
                "time": "@date(yyyy-MM-dd)"
            }],
            "rankinglist|10": [{
                "href": "#",
                "img": "@image(85x98,@color)",
                "title": "@ctitle(8,10)",
                "num|500-2000": 1,
                "time": "@date(yyyy/MM/dd)"
            }]
        },
        //聚设计
        "jsheji|4": [{
            "href": "#",
            "works": "@image(285x260,@color)",
            "designer": "@image(112x112,@color)",
            "name": "@name",
            "source": "@ctitle(5,8)"
        }],
        //聚品牌
        "jpinpai": {
            "bannerlist|3": [{
                "href": "#",
                "banner": "@image(386x290,@color)",
                "icon": "@image(180x64,#fff)",
                "shopname": "@ctitle(6,12)",
                "text": "@ctitle(8,14)"
            }],
            "iconlist|12": ["@image(180x64,@color)"]
        },
        //聚好款
        "jhaokuang": {
            "lefticon|4": [{
                "img": "@image(180x64,@color)",
                "href": "#"
            }],
            "navlist|4": [{
                "title|1": ["女装", "男装", "童装", "工作服"],
                "subnavlist|5-10": [{
                    "text": "@ctitle(2,3)",
                    "href": "#"
                }]
            }],
            "weeklist|6-10": [{
                "href": "#",
                "img": "@image(85x98,@color)",
                "goods": "@ctitle(3,5)",
                "money|100-999.2": 1,
                "company": "@ctitle(8,14)",
                "position": "广东  深圳市"
            }]
        },
        //聚服务
        "jfuwu": {
            "total": "1,668,964",
            "msglist|3": [{
                "banner": "@image(300x350,@color)",
                "type|1": ["找设计", "找打样", "找款型"],
                "begin": "@date(yyyy/mm/dd)",
                "position": "广东 广州市",
                "end": "@date(yyyy/mm/dd)",
                "href": "#"
            }]
        },
        //聚衣会
        "jyihui": {
            "leftbanner": "@image(340x450,@color)",
            "msglist|4": [{
                "title": "@ctitle(6,12)",
                "position": "@ctitle(6,12)",
                "time": "2017/12/20~12/25",
                "href": "#",
                "img": "@image(110x110,@color)"
            }]
        },
        //聚企业
        "jqiye": {
            "comlist|3": [{
                "company": "@ctitle(10,16)",
                "position": "@ctitle(8,12)",
                "collect": "12.9万",
                "href": "#",
                "goodslist|3": [{
                    "href": "#",
                    "img": "@image(100x120,@color)",
                    "price|10-99.2": 1
                }]
            }],
            "newslist|3": [{
                "news|3": [{
                    "time": "@date(mm-dd)",
                    "text": "@ctitle(15,30)",
                    "href": "#"
                }],
            }]
        }
    });
    index = new Vue({
        el: "#index",
        data() {
            return {
                location: '',
                loginName: '',
                greetState: "", //当前时间状态 早上，上午，中午，下午，晚上
                indexSearch: [{
                        title: "工厂类型",
                        cur: "", //当前选中项
                        show: 0, //控制 下拉选择框 显示隐藏 0隐藏 1显示
                        option: [],
                    },
                    {
                        title: "地区要求",
                        cur: "",
                        show: 0,
                        option: [],
                    }
                ],
                area: '', //一键找厂地区
                companyType: '', //一键找厂公司类型
                q: '', //一键找厂关键字
                //订单总数
                dingdan: {
                    total: "27,202",
                    msg: [
                        ["江苏", "针织", "1,200件"],
                        ["江苏", "针织", "1,200件"],
                        ["江苏", "针织", "1,200件"],
                        ["江苏", "针织", "1,200件"],
                    ]
                },
                //三个月总销售
                xiaoshou: {
                    total: "27,202",
                    msg: [
                        ["针织类", "1,000件", "8,200元"],
                        ["针织类", "1,000件", "8,200元"],
                        ["针织类", "1,000件", "8,200元"],
                        ["针织类", "1,000件", "8,200元"],
                    ]
                },
                rankingFocus: 1, //订单排行榜 当前显示的
                weekFocus: 1, //聚好款 本周上新 当前显示的
                jqiyenewsTitle: ["学院头条", "热门帖子", "行业资讯"], //聚企业 资讯标题
                jqiyenewsImg: ["../../img/index_jqiye_news1.png", "../../img/index_jqiye_news2.png", "../../img/index_jqiye_news3.png"],
                bannerLeftNavList: [], //左侧导航
                bannerLeftNavList2: [], //左侧导航
                bannerLeftNavList3: [], //左侧导航
                bannerlist: [], //banner轮播图,
                noticeList: [], //公告
                factoryTypeList: [], //工厂类型
                provinceList: [], //省
                factoryType: '', //工厂类型
                userInfo: '',
                brandLogos: [], //具品牌logo,
                juxueyuan: {
                    toutiao: [], //头条
                    tiezi: [], //帖子
                    zixun: [] //资讯
                }
            }
        },
        methods: {
            getData() {
                this.loginName = urlParam.loginName();
                this.bannerLeftNavList = mockData.bannerLeftNavList; //左侧导航
                // this.bannerlist = mockData.bannerlist; //banner轮播图
                this.userHead = mockData.userHead; //用户头像 未登录时没有图片,有背景图显示
                this.userName = mockData.userName; //用户名 未登录时没有用户名，页面显示 Hi
                this.noticeNav = mockData.noticeNav; //banner区 公告
                this.jdingdan = mockData.jdingdan; //聚订单
                this.jsheji = mockData.jsheji; //聚设计
                this.jpinpai = mockData.jpinpai; //聚品牌
                this.jhaokuang = mockData.jhaokuang; //聚好款
                this.jfuwu = mockData.jfuwu; //聚服务
                this.jyihui = mockData.jyihui; //聚衣会
                this.jqiye = mockData.jqiye; //聚企业
                this.greetState = (function() {
                    var hours = globalAPI.getDate({ format: "hh" }) - 0;
                    if (hours > 4 && hours < 7) {
                        return "早上";
                    } else if (hours >= 7 && hours < 11) {
                        return "上午";
                    } else if (hours >= 11 && hours < 13) {
                        return "中午";
                    } else if (hours >= 13 && hours < 18) {
                        return "下午";
                    } else if ((hours >= 18 && hours < 24) || (hours >= 0 && hours <= 4)) {
                        return "晚上";
                    }
                })();

                let that = this;

                //获取首页信息
                axios.get(urlParam.domain() + '/api/index/list', {
                    params: {
                        token: urlParam.token(),
                        position: urlParam.indexPosition()
                    }
                }).then(function(response) {
                    if (response.data.data != undefined) {
                        that.bannerlist = response.data.data.banner; //轮播图
                        that.bannerLeftNavList = response.data.data.categoryMaps.dressCategory; //聚订单-服饰分类
                        that.bannerLeftNavList2 = response.data.data.categoryMaps.materialCategory; //聚订单-面料分类
                        that.bannerLeftNavList3 = response.data.data.categoryMaps.accessoriesCategory; //聚订单-辅料分类
                        that.jsheji = response.data.data.designers; //聚设计
                        that.jfuwu = response.data.data.demands; //聚服务
                        that.jfuwu.total = response.data.data.demandsTotal; //聚服务

                        that.jpinpai = response.data.data.brands; //聚品牌
                        that.brandLogos = response.data.data.brandLogos; //聚品牌logo
                        that.jyihui = response.data.data.purchasingMeetings; //聚衣会（目前仅是名企采购）

                        that.jhaokuang.navlist = response.data.data.goodsCategoryList;
                        that.jhaokuang.weeklist = response.data.data.goods;
                        that.jhaokuang.lefticon = that.jhaokuang.weeklist[6].company.brands;

                        that.jqiye.comlist = response.data.data.indexCompany; //聚企业
                        that.juxueyuan = response.data.data.informationList; //聚学院
                        that.noticeList = response.data.data.noticeList; //公告

                        console.log(that.juxueyuan);

                        that.userInfo = response.data.data.userInfo;

                        that.indexSearch[0].option = response.data.data.factoryTypeList;
                        that.indexSearch[1].option = response.data.data.provinceList;


                        console.log(response.data.data);
                        // console.log(that.jfuwu);
                    }
                }).then(function() {
                    that.initBanner();
                });
            },
            initBanner() {
                new Swiper('.index_banner-center-swiper', {
                    loop: true, //让Swiper看起来是循环的。
                    effect: 'fade', //默认为" slide "（位移切换），可设置为" fade " 淡入 "  cube " 方块  " coverflow " 3d流  " flip " 3d翻转 。
                    speed: 1000,
                    autoplay: {
                        delay: 4000,
                        disableOnInteraction: false, //用户操作swiper之后，是否禁止autoplay。默认为true：停止
                    },
                    pagination: { //分页器
                        el: '.swiper-pagination', //设置分页器，默认null
                        type: 'bullets', //分页器样式类型 ‘bullets’  圆点（默认）‘fraction’  分式  ‘progress’  进度条
                        clickable: true, //点击分页器的指示点分页器会控制Swipe
                    },
                });
            },
            //点击选择 显示、隐藏下拉框
            clickSearchOption(index) {
                this.indexSearch[index].show == 0 ? this.indexSearch[index].show = 1 : this.indexSearch[index].show = 0;
            },
            //点击下拉框中的选项
            clickSubOptin(index, subindex) {
                this.indexSearch[index].show = 0;
                if (index == 0) {
                    this.indexSearch[index].cur = this.indexSearch[index].option[subindex].name;
                    this.companyType = this.indexSearch[index].option[subindex].id;
                } else {
                    this.indexSearch[index].cur = this.indexSearch[index].option[subindex].areaname;
                    this.area = this.indexSearch[index].option[subindex].id;
                }
                console.log(this.indexSearch[index].cur);
            },
            //点击订单排行榜 焦点
            clickRanking(index) {
                this.rankingFocus = index;
            },
            //点击聚好款 本周上新 焦点
            clickWeek(index) {
                this.weekFocus = index;
            },
            //注册
            registration: function() {
                window.location.href = this.location + "/index/registration.html";
            },
            //登录
            login: function() {
                window.location.href = this.location + "/index/login.html"
            },
            //获取聚订单信息
            jdingdanData: function() {
                let that = this;
                axios.get(urlParam.domain() + '/api/order/order/indexReleasedList', {
                    params: {
                        token: urlParam.token()

                    }
                }).then(function(response) {
                    console.log("*************");
                    console.log(response.data.data);
                    that.jdingdan.total = response.data.data.total;
                    that.jdingdan.bannerlist = response.data.data.releaseList;
                    that.jdingdan.rankinglist = response.data.data.purchaseList;
                });
            },

            //聚订单发布询盘
            judingdanFaBu: function() {
                let token = urlParam.token();
                if (token == '') {
                    this.$message({ message: '请先登录', type: 'warning' });
                } else {
                    window.location.href = this.location + "/jdingdan/xunpan.html";
                }
            },
            //聚订单报价
            judingdanBaoJia: function(id) {
                let token = urlParam.token();
                if (token == '') {
                    this.$message({ message: '请先登录', type: 'warning' });
                    return;
                }
                if (!this.userInfo.seller) {
                    this.$message({ message: '该用户尚未完成入驻，请先申请入驻', type: 'warning' });
                    return;
                } else {
                    window.location.href = this.location + "/jdingdan/baojia.html?" + id;
                }
            },

            //聚服务发布需求
            jufuwuFaBu: function() {
                let token = urlParam.token();
                if (token == '') {
                    this.$message({ message: '请先登录', type: 'warning' });
                } else {
                    window.location.href = this.location + "/jfuwu/xuqiu.html";
                }
            },
            //聚服务发布报价
            jufuwuBaoJia: function(demandId) {
                let token = urlParam.token();
                if (token == '') {
                    this.$message({ message: '请先登录', type: 'warning' });
                    return;
                }
                if (!this.userInfo.seller) {
                    this.$message({ message: '该用户尚未完成入驻，请先申请入驻', type: 'warning' });
                    return;
                } else {
                    window.location.href = this.location + "/jfuwu/baojia.html?" + demandId;
                }
            },
            //聚设计查看作品
            targetDesigner: function(designerId) {
                let token = urlParam.token();
                if (token == '') {
                    this.$message({ message: '请先登录', type: 'warning' });
                } else {
                    window.location.href = this.location + "/jsheji/designer_info_for_user.html?id=" + designerId;
                }
            },
            //聚设计找TA设计
            targetPublish: function(designerId) {
                let token = urlParam.token();
                if (token == '') {
                    this.$message({ message: '请先登录', type: 'warning' });
                } else {
                    window.location.href = this.location + "/jfuwu/xuqiu.html?designerId=" + designerId;
                }
            },

            //聚企业-关注
            addFollow(data) {
                if (urlParam.token() == null || urlParam.token() == "") {
                    this.$message({ message: "请先登录", type: "warning" });
                    return;
                }
                var that = this;
                axios({
                    method: "post",
                    url: urlParam.domain() + '/api/company/companyFollow/add',
                    data: {
                        token: urlParam.token(),
                        companyId: data
                    },
                    transformRequest: [function(data) {
                        let ret = ''
                        for (let it in data) {
                            ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
                        }
                        return ret
                    }],
                }).then(function(response) {
                    that.$message({
                        message: "关注成功",
                        type: "success"
                    });
                    that.getData();
                });
            },
            //聚企业-取消关注
            delFollow(data) {
                var that = this;
                axios.get(urlParam.domain() + '/api/company/companyFollow/delete', {
                    params: {
                        ids: data + ",",
                        token: urlParam.token()
                    }
                }).then(function(response) {
                    that.$message({
                        message: "取消关注成功",
                        type: "success"
                    });
                    that.getData();
                });
            },

            //第三方登录
            thirdLogin() {
                console.log("#########################");
                let that = this;
                let parma = location.href.split("code=");
                console.log("------" + parma);

                if (parma != 'undefined' && parma.length > 1) {
                    let code = parma[1].split("&")[0];
                    console.log("获取---" + code);
                    axios.get(urlParam.domain() + '/api/user/wxLogin?code=' + code)
                        .then(function(res) {
                            if (res.data.code == 1) {
                                console.log("-----------" + res.data.data.loginName);
                                console.log("---------------" + res.data.data.token);
                                globalAPI.setCookie("token", res.data.data.token, 5);
                                globalAPI.setCookie("username", res.data.data.loginName, 5);
                                that.loginName = res.data.data.loginName;
                            }
                        })
                }
            },

            //一键找厂
            searchCompany() {
                var area = this.area;
                var companyType = this.companyType;
                var q = this.q;
                window.location.href = this.location + "/jqiye/jqiye_list.html?area="+area+"&companyType="+companyType+"&q="+q;
            }
        },
        created() {
            this.location = urlParam.location();
            this.thirdLogin();
            this.getData();
            this.jdingdanData();
        },
        mounted() {
            // this.initBanner();
        },
        components: {}
    });
}

//登录
function index_login() {
    let mockData = Mock.mock({});
    new Vue({
        el: "#index_login",
        data() {
            return {
                loginshow: 0, //0为手机号登录 1为微信登录
                loginUser: {
                    loginName: '',
                    loginPassword: '',
                },
                remPwd: 0, //记住密码 0 为不选中 1为选中
                loginError: false
            }
        },
        methods: {
            getData() {
                // this.quan = mockData.quan;
            },
            clickloginshow(n) {
                this.loginshow = n;
            },
            //点击登录
            loginButton: function() {
                let that = this;
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/user/login',
                    responseType: 'stream',
                    data: formartPostParms(this.loginUser),
                }).then(function(r) {
                    console.log(r)
                    if (r.data.code == 1) {
                        globalAPI.setCookie("username", that.loginUser.loginName, 5);
                        globalAPI.setCookie("token", JSON.stringify(r.data.data.token), 5);
                        var redirectUrl = globalAPI.readCookie("redirectUrl");
                        if(redirectUrl){
                            window.location.href = redirectUrl;
                        }else{
                            window.location.href = '../index/index1.html';
                        }
                    } else {
                        that.loginError = true
                    }
                });
            }
        },
        created() {
            this.getData();
        },
        mounted() {

        },
        components: {}
    });
}

//注册
function index_res() {
    let mockData = Mock.mock({});
    new Vue({
        el: "#index_res",
        data() {
            return {
                resagree: 0, //是否同意 用户注册协议和隐私注册 初始为0，不同意 1为同意
                codeButton: '获取验证码',
                timer: 60,
                registerInfo: {
                    loginPassword: '',
                    reloginPassword: '', //重复密码
                    telephone: '',
                    userName: '',
                    verificationCode: '',
                }

            }
        },
        methods: {
            getData() {
                // this.quan = mockData.quan;
            },
            //点击 同意注册协议
            clickresagree() {
                this.resagree == 0 ? this.resagree = 1 : this.resagree = 0;
            },

            //发送验证码
            sendCode: function(e) {
                var that = this;
                if (this.codeButton != '获取验证码') {
                    return false;
                }
                if (this.registerInfo.telephone == '') {
                    alert('手机号码不能为空！');
                    return false;
                }
                if (!(/^1[345678][0-9]{9}$/.test(this.registerInfo.telephone))) {
                    alert('手机号码格式不正确！');
                    return false;
                }
                that.codeButton = that.timer + '秒';
                axios({
                        method: 'get',
                        url: urlParam.domain() + '/api/sms/sendVerifyCode?telephone=' + this.registerInfo.telephone,
                        responseType: 'stream'
                    })
                    .then(function(r) {
                        if (r.data.code == 0) {
                            alert(r.data.message);
                        } else {
                            var intv = setInterval(function() {
                                that.timer--;
                                if (that.timer <= 0) {
                                    clearInterval(intv);
                                    that.codeButton = '获取验证码';
                                } else {
                                    that.codeButton = that.timer + '秒';
                                }
                            }, 1000)
                        }
                    })
            },

            register: function() {
                var info = this.registerInfo;
                if (this.resagree == 0) {
                    alert('请阅读注册协议！');
                    return false;
                }
                if (info.telephone == '') {
                    alert('手机号码不能为空！');
                    return false;
                }
                if (!(/^1[345678][0-9]{9}$/.test(info.telephone))) {
                    alert('手机号码格式不正确！');
                    return false;
                }
                if (info.userName == '') {
                    alert('昵称不能为空！');
                    return false;
                }
                if (info.reloginPassword == '' || info.loginPassword == '') {
                    alert('密码不能为空！');
                    return false;
                }
                if (info.reloginPassword != info.loginPassword) {
                    alert('两次密码不一致！');
                    return false;
                }

                if (info.verificationCode == '') {
                    alert('验证码不能为空！');
                    return false;
                }

                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/user/register',
                    data: formartPostParms(info),
                    responseType: 'stream'
                }).then(function(r) {
                    if (r.data.code == '425') {
                        alert("该手机号已经被注册")
                    } else {
                        alert("注册成功")
                        window.location.href = "login.html";
                    }
                })
            }
        },
        created() {
            this.getData();
        },
        mounted() {

        },
        components: {}
    });
}

// 忘记密码 第一步
function forget_pwd1() {
    let mockData = Mock.mock({});
    new Vue({
        el: "#forget_pwd1",
        data() {
            return {
                tel: ''
            }
        },
        methods: {
            getData() {
                // this.quan = mockData.quan;
            },
            next: function() {
                if (!(/^1[34578]\d{9}$/.test(this.tel))) {
                    alert("手机号码有误，请重填");
                } else {
                    location.href = 'forget_pw2.html?' + this.tel
                }
            }
        },
        created() {
            this.getData();
        },
        mounted() {

        },
        components: {}
    });
}

// 忘记密码 第二步
function forget_pwd2() {
    let mockData = Mock.mock({});
    new Vue({
        el: "#forget_pwd2",
        data() {
            return {
                tel: ''
            }
        },
        methods: {
            getData() {
                this.tel = window.location.href.split("?")[1];
            },
        },
        created() {
            this.getData();
        },
        mounted() {

        },
        components: {}
    });
}

// 忘记密码 第三步
function forget_pwd3() {
    let mockData = Mock.mock({});
    new Vue({
        el: "#forget_pwd3",
        data() {
            return {}
        },
        methods: {
            getData() {
                // this.quan = mockData.quan;
            },
        },
        created() {
            this.getData();
        },
        mounted() {

        },
        components: {}
    });
}

// 忘记密码 第四步
function forget_pwd4() {
    let mockData = Mock.mock({});
    new Vue({
        el: "#forget_pwd4",
        data() {
            return {}
        },
        methods: {
            getData() {
                // this.quan = mockData.quan;
            },
        },
        created() {
            this.getData();
        },
        mounted() {

        },
        components: {}
    });
}

//企业入驻
function company_entry() {
    let mockData = Mock.mock({
        /*"companyTypeList|4-6": [{ //企业类型 下拉框的选项
            "text": "@ctitle(4,6)",
            "id|+1": 0,
        }],*/
        "licenseTypeList|4-6": [{
            "text": "@ctitle(4,6)",
            "id|+1": 0,
        }]

    });
    company_entry = new Vue({
        el: "#company_entry",
        data() {
            return {
                step: 1, //当前进度，一共五步，起始是第一步
                waitUpImg: "../../img/company_entry_upimg.png", //上传图片 显示预览图之前的图片
                area: area, //省市区 josn <script src="../../lib/js/area.js"></script> 引入

                //第一步 企业信息 ***********************************************************************************

                companyTypeList: [], //企业类型 下拉框的选项
                companyTypeActive: "", //选中的 企业类型 文字
                companyTypeIndex: -1, //控制 企业类型 选项哪个被选中 默认没有
                companyTypeId: "", //id
                companyLogo: { //企业 logo
                    base64: [""], //企业 logo base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                companyProvince: "", //省
                companyProvinceId: -1, //省id
                companyProvinceIndex: -1, //省 选中项下标 用于显示选中项
                companyCityList: [], //市 生成选项的数组
                companyCity: "", //市
                companyCityId: -1, //市 id
                companyCityIndex: -1, //市 选中项下标 用于显示选中项
                companyAreaList: [], //市 生成选项的数组
                companyArea: "", //区
                companyAreaId: -1, //区 id
                companyAreaIndex: -1, //区 选中项下标 用于显示选中项
                //企业信息（手动添加）
                companyAdress: "",
                mobile: "",
                introduce: "",
                employees: "",
                companyName: "",
                //第二步 营业执照信息 license *************************************************************************************
                licenseTypeList: [{
                        "text": "普通执照",
                        "id": 1,
                    },
                    {
                        "text": "多证合一/非统一社会信用代码",
                        "id": 2,
                    },
                    {
                        "text": "多证合一/统一社会信用代码",
                        "id": 3,
                    }
                ], //执照类型下拉选择项
                licenseTypeText: "", //选中的类型文字
                licenseTypeId: "", //id
                licenseTypeIndex: "", //数组下标 用于显示那个被选中
                licenseCode: "", //营业执照注册号
                licenseName: "", //法定代表人姓名

                licenseProvince: "", //省
                licenseProvinceId: -1, //省id
                licenseProvinceIndex: -1, //省 选中项下标 用于显示选中项
                licenseCityList: [], //市 生成选项的数组
                licenseCity: "", //市
                licenseCityId: -1, //市 id
                licenseCityIndex: -1, //市 选中项下标 用于显示选中项
                licenseAreaList: [], //市 生成选项的数组
                licenseArea: "", //区
                licenseAreaId: -1, //区 id
                licenseAreaIndex: -1, //区 选中项下标 用于显示选中项

                licenseAddress: "", //营业执照详细地址
                licenseFoundTime: "", //成立时间
                licenseTermBegin: "", //营业期限 开始时间
                licenseTermEnd: "", //营业期限 结束时间
                licenseCapital: "", //注册资本

                businessScope: "", //经营范围

                licenseIDOne: { //身份证 正面
                    base64: [""], //base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                licenseIDTwo: { //身份证 反面
                    base64: [""], //base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                licensePic: { //营业执照电子版
                    base64: [""], //base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },

                //第三步 组织机构代码证 organ *************************************************************************************
                organCode: "", //组织机构代码
                organTermBegin: "", //组织机构代码证有效期 开始时间
                organTermEnd: "", //结束时间
                organPic: { //营业执照电子版
                    base64: [""], //base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },

                //第四步 税务登记证 tax *************************************************************************************
                //纳税人类型下拉选择项
                /*taxType: "", //纳税人类型*/
                taxTypeText: "", //选中的类型文字
                taxTypeId: "", //id
                taxTypeIndex: "", //数组下标 用于显示那个被选中
                taxTypeList: [{
                        "text": "一般纳税人",
                        "id": 1,
                    },
                    {
                        "text": "小规模纳税人",
                        "id": 2,
                    },
                    {
                        "text": "增值纳税人",
                        "id": 3,
                    }
                ],

                //纳税人类型下拉选择项
                /*taxTypeCode: "", //纳税类型税码*/
                taxTypeCodeText: "", //选中的类型文字
                taxTypeCodeId: "", //id
                taxTypeCodeIndex: "", //数组下标 用于显示那个被选中
                taxTypeCodeList: [{
                        "text": "0%",
                        "id": 0,
                    },
                    {
                        "text": "3%",
                        "id": 3,
                    },
                    {
                        "text": "6%",
                        "id": 6,
                    },
                    {
                        "text": "10%",
                        "id": 10,
                    }
                ],

                taxCode: "", //纳税人识别号

                taxPic: { //税务登记证电子版
                    base64: [""], //base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                taxPeoplePic: { //一般纳税人资格证电子版
                    base64: [""], //base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },

                //第四步 开户银行许可证 bank *************************************************************************************
                bankName: "", //银行开户名
                bankNum: "", //公司银行账号
                bankBigBum: "", //大额行号
                bankBranchName: "", //开户银行支行名称
                bankBranchNum: "", //开户银行支行联行号
                //开户银行支行所在地
                bankProvince: "", //省
                bankProvinceId: -1, //省id
                bankProvinceIndex: -1, //省 选中项下标 用于显示选中项
                bankCityList: [], //市 生成选项的数组
                bankCity: "", //市
                bankCityId: -1, //市 id
                bankCityIndex: -1, //市 选中项下标 用于显示选中项
                bankAreaList: [], //市 生成选项的数组
                bankArea: "", //区
                bankAreaId: -1, //区 id
                bankAreaIndex: -1, //区 选中项下标 用于显示选中项

                bankPic: { //银行开户许可证电子版
                    base64: [""], //base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },

                submitjosn: { //ajax提交的josn信息
                    companyId: "", //企业id
                },
                href:decodeURI(window.location.href),
            }
        },
        methods: {
            getData() {
                let that = this;
                //this.companyTypeList = mockData.companyTypeList; //企业类型 下拉框的选项
                //console.log(window.location.href);
                if(that.href.indexOf("?")!=-1){
                   var id= globalAPI.getRequest()["id"];
                    axios.get(urlParam.domain() + '/api/dict/query', {
                        params: {
                            name: '企业类型'
                        }
                    }).then(function(response) {
                        if (response.data.code == 1) {
                            if (response.data.data != undefined) {
                                that.companyTypeList = response.data.data;
                            }
                        }
                    })
                }

                axios.get(urlParam.domain() + '/api/dict/query', {
                    params: {
                        name: '企业类型'
                    }
                }).then(function(response) {
                    if (response.data.code == 1) {
                        if (response.data.data != undefined) {
                            that.companyTypeList = response.data.data;
                        }
                    }

                });

                //this.licenseTypeList = mockData.licenseTypeList; //执照类型下拉选择项
            },
            //点击选择 显示下拉框
            clickShowOption(e) {
                e.currentTarget.nextElementSibling.style.display = "block";
            },
            //鼠标移出 关闭下拉框
            closeOption(e) {
                e.currentTarget.getElementsByClassName("con-col-option-sub")[0].style.display = "none";
            },
            //点击 省
            clickProvince(text, id, index, data) {
                this[data + "Province"] = text;
                this[data + "ProvinceId"] = id;
                this[data + "ProvinceIndex"] = index;
                //清空 市 选项
                this[data + "City"] = "";
                this[data + "CityId"] = -1;
                this[data + "CityIndex"] = -1;
                //清空 区 选项
                this[data + "Area"] = "";
                this[data + "AreaId"] = -1;
                this[data + "AreaIndex"] = -1;
                this[data + "AreaList"] = [];
                //生成 市 选项
                this[data + "CityList"] = area[index].children;
            },
            //点击 市
            clickCity(text, id, index, data) {
                this[data + "City"] = text;
                this[data + "CityId"] = id;
                this[data + "CityIndex"] = index;
                //清空 区 选项
                this[data + "Area"] = "";
                this[data + "AreaId"] = -1;
                this[data + "AreaIndex"] = -1;
                //生成 区 选项
                this[data + "AreaList"] = this[data + "CityList"][index].children;
            },
            //点击 区
            clickArea(text, id, index, data) {
                this[data + "Area"] = text;
                this[data + "AreaId"] = id;
                this[data + "AreaIndex"] = index;
            },
            //第一步
            //点击 企业类型 下拉框选项
            clickCompanyTypeOption(index, name, id) {

                this.companyTypeActive = name; //显示文字
                this.companyTypeIndex = index; //更改被选中项 选中样式
                this.companyTypeId = id; //id
            },
            //点击 下一步  验证成功后跳到下一步
            clickNextStep1() {

                this.step = 2;
            },
            //第一步 end ***************************************************************************
            //第二步 ***************************************************************************
            //点击 执照类型 下拉选项
            clickLicenseTypeOption(index, text, id) {
                this.licenseTypeIndex = index;
                this.licenseTypeText = text;
                this.licenseTypeId = id;
            },
            //点击 上一步
            clickPrevStep2() {
                this.step = 1;
            },
            //点击 下一步 验证
            clickNextStep2() {
                this.step = 3;
            },
            //第二步 end ***************************************************************************
            //第三步 ***************************************************************************
            //点击 上一步
            clickPrevStep3() {
                this.step = 2;
            },
            //点击 下一步 验证
            clickNextStep3() {
                this.step = 4;
            },
            //第三步 end ***************************************************************************
            //第四步 ***************************************************************************
            //点击 执照类型 下拉选项
            clickTaxTypeOption(index, text, id) {
                this.taxTypeIndex = index;
                this.taxTypeText = text;
                this.taxTypeId = id;
            },
            //点击 纳税类型 下拉选项
            clickTaxTypeCodeOption(index, text, id) {
                this.taxTypeCodeIndex = index;
                this.taxTypeCodeText = text;
                this.taxTypeCodeId = id;
            },
            clickPrevStep4() {
                this.step = 3;
            },
            //点击 下一步 验证
            clickNextStep4() {
                this.step = 5;
            },
            //第四步 end ***************************************************************************
            //第五步 ***************************************************************************
            clickPrevStep5() {
                this.step = 4;
            },
            //点击 提交入驻申请 验证
            clickNextStep5(e) {
                var obj = e.currentTarget; //这个提交按钮
                hrefJudge = true; //ajax提交成功之后 页面跳转时不再出现二次提示框
                console.log("ajax提交");
                let that = this;
                //公司对象里面的相关图片的list集合
                var pic = { fileUrl: "" };
                var businessLicenseUrls = [];
                var codeCertificateUrls = [];
                var taxRegistrationCertificate = [];
                var generalTaxpayerQualificationCertificate = [];
                var openBankAccountPermitCertificate = [];

                for (var i = 0; i < that.licensePic.url.length; i++) {
                    pic.fileUrl = that.licensePic.url[i];
                    businessLicenseUrls[i] = pic;
                }
                for (var i = 0; i < that.organPic.url.length; i++) {
                    pic.fileUrl = that.organPic.url[i];
                    codeCertificateUrls[i] = pic;
                }
                for (var i = 0; i < that.taxPic.url.length; i++) {
                    pic.fileUrl = that.taxPic.url[i];
                    taxRegistrationCertificate[i] = pic;
                }
                for (var i = 0; i < that.taxPeoplePic.url.length; i++) {
                    pic.fileUrl = that.taxPeoplePic.url[i];
                    generalTaxpayerQualificationCertificate[i] = pic;
                }
                for (var i = 0; i < that.bankPic.url.length; i++) {
                    pic.fileUrl = that.bankPic.url[i];
                    openBankAccountPermitCertificate[i] = pic;
                }
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/company/company/addPC',
                    dataType: 'json',
                    headers: { "token": urlParam.token(), "Content-Type": "application/json" },
                    data: {
                        //1企业信息
                        name: that.companyName, //企业名称
                        categoryId: that.companyTypeId, //企业类型
                        logoUrl: that.companyLogo.url[0], //企业logoUrl
                        provinceId: that.companyProvinceId, //省
                        cityId: that.companyCityId, //市
                        areaId: that.companyAreaId, //区
                        companyAdress: that.companyAdress, //企业地址
                        mobile: that.mobile, //企业电话
                        employees: that.employees, //员工人数
                        introduce: that.introduce, //企业介绍
                        //2营业执照信息
                        businessLicense: {
                            categoryId: that.licenseTypeId, //营业执照类型
                            categoryNo: that.licenseCode, //营业执照注册号
                            corporation: that.licenseName, //法定代表人姓名
                            provinceId: that.licenseProvinceId, //省
                            cityId: that.licenseCityId, //市
                            areaId: that.licenseAreaId, //区
                            licenseAdress: that.licenseAddress, //地址
                            capitalDate: that.licenseFoundTime, //成立时间
                            businessTerm: that.licenseTermBegin, //营业期限开始时间
                            businessTermEnd: that.licenseTermEnd, //营业期限结束时间
                            registeredCapital: that.licenseCapital, //注册资本
                            businessScope: that.businessScope //经营范围
                        },

                        //3组织机构代码证
                        codeCertificate: {
                            organizationCode: that.organCode, //组织机构代码
                            certificateTerm: that.organTermBegin, //组织机构代码证期限(开始时间)
                            certificateTermEnd: that.organTermEnd //组织机构代码证期限(结束时间)

                        },
                        //4税务登记证
                        registrationCertificate: {
                            taxpayerIdentificationNumber: that.taxCode, //纳税人识别号
                            taxpayerCategoryId: that.taxTypeId, //纳税人类型
                            taxCodeCategoryId: that.taxTypeCodeId //纳税类型税码
                        },
                        //5开户银行许可证
                        bankLicense: {
                            accountTitle: that.bankName, //银行开户名
                            accountNum: that.bankNum, //公司银行账号
                            largeBankNo: that.bankBigBum, //大额行号
                            bank: that.bankBranchName, //开户银行支行名称
                            coupletNumbe: that.bankBranchNum, //开户银行支行联行号
                            provinceId: that.bankProvinceId, //省
                            cityId: that.bankCityId, //市
                            areaId: that.bankAreaId, //区

                        },
                        //6其它
                        //2.1法人证件照
                        legalManLicenceUrls: [
                            { fileUrl: that.licenseIDOne.url[0] },
                            { fileUrl: that.licenseIDTwo.url[0] }
                        ],
                        //2.2营业执照照片
                        businessLicenseUrls: businessLicenseUrls,
                        //3.1组织机构代码证电子版照片
                        codeCertificateUrls: codeCertificateUrls,
                        //4.1税务登记证
                        taxRegistrationCertificate: taxRegistrationCertificate,
                        //4.2一般纳税人
                        generalTaxpayerQualificationCertificate: generalTaxpayerQualificationCertificate,
                        //5.1银行开户许可证-图片
                        openBankAccountPermitCertificate: openBankAccountPermitCertificate
                    },
                }).then(
                    that.$message({
                        message: '新增成功',
                        type: 'success'
                    })
                );

                obj.setAttribute("disabled", "disabled"); //阻止按钮点击事件，防止多次点击多次ajax提交
                //obj.removeAttribute("disabled"); //ajax提交失败的时候允许继续点击去ajax提交
            },
            //第五步 end ***************************************************************************
        },

        created() {
            this.getData();
        },
        mounted() {

        },
    });
}

//聚品牌_品牌入驻
function pinpai_entry() {
    let mockData = Mock.mock({
        "pinpaiStyle|9-18": [{
            "text": "@ctitle(4,4)",
            "id|+1": 0,
        }]
    });
    pinpai_entry = new Vue({
        el: "#pinpai_entry",
        data() {
            return {
                companyName: "企业名称", //企业名称 判断是否登录，从用户信息中读取 企业名称
                pinpaiName: "", //品牌名称
                pinpaiLogo: { //品牌 logo
                    base64: [""], //base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                upTime: "", //成立时间
                pinpaiStyle: [], //品牌风格
                minage: "", //最小 消费人群 年龄
                maxage: "", //最小
                zhenshu: { //品牌证书电子版
                    base64: [""], //base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                contacts: "", //联系人
                tel: "", //联系方式
            }
        },
        methods: {
            getData() {
                this.pinpaiStyle = mockData.pinpaiStyle;
            },
            //点击 品牌风格 选项 多选
            clickPinpaiStyle(index) {
                //想对象中添加 cur 属性，用来判断此选项是否被选中
                if (this.pinpaiStyle[index].cur) {
                    this.$set(this.pinpaiStyle[index], "cur", false);
                } else {
                    this.$set(this.pinpaiStyle[index], "cur", true);
                }
            },
            //得到选中的 品牌风格 选项 id 返回一个数组
            getPinpaiStyle() {
                var arr = [];
                for (var i = 0; i < this.pinpaiStyle.length; i++) {
                    if (this.pinpaiStyle[i].cur) {
                        arr.push(this.pinpaiStyle[i].id)
                    }
                }
                return arr;
            },
            //提交品牌申请 验证成功后跳转页面
            clickSubmit(e) {
                console.log("提交");
                var obj = e.currentTarget; //这个提交按钮
                obj.setAttribute("disabled", "disabled"); //阻止按钮点击事件，防止多次点击多次ajax提交
                //obj.removeAttribute("disabled"); //ajax提交失败的时候允许继续点击去ajax提交
            }
        },
        created() {
            this.getData();
        },
        mounted() {

        },
        components: {}
    });
}

//品牌入驻_审核进度
function pinpai_entry_review() {
    let mockData = Mock.mock({});
    pinpai_entry_review = new Vue({
        el: "#pinpai_entry_review",
        data() {
            return {
                step: 1, //进度
            }
        },
        methods: {
            getData() {
                // this.quan = mockData.quan;
            },
            //点击返回
            clickBack() {
                history.back();
            }
        },
        created() {
            this.getData();
        },
        mounted() {

        },
        components: {}
    });
}

//公告列表页
function gongg_list() {
    new Vue({
        el: "#gongg_list",
        data() {
            return {
                list: [],
                total: 0,
                pageNo: 1,
                pageSize: 12,
                title: "",
                createTime: "",
                messages: ""
            }
        },
        methods: {
            getData() {
                var that = this;
                axios.get(urlParam.domain() + '/api/notices/list', {
                        params: {
                            pageNo: that.pageNo,
                            pageSize: that.pageSize
                        }
                    })
                    .then(function(response) {
                        let pageDate = response.data.data;
                        that.list = pageDate.list;
                        that.total = Math.ceil(response.data.data.total / that.pageSize);
                    });

            },
            getPage(page) {
                this.pageNo = page;
                this.getData();
            }
        },
        created() {
            this.location = urlParam.location();
            this.getData();
        }
    });
}

//公告详情页
function gg_detail() {
    let mockData = Mock.mock({
        'notice': {},
    });
    new Vue({
        el: "#gg_detail",
        data() {
            return {
                id: urlParam.href().id,
                notice: {},
            }
        },
        methods: {
            getData() {
                var that = this;
                axios.get(urlParam.domain() + '/api/notices/detail/?id=' + this.id, {
                    params: {
                        token: urlParam.token(),
                        id: that.id
                    }
                }).then(function(response) {
                    console.log(response.data.data);
                    that.notice = response.data.data;
                });

            }
        },
        created() {
            console.log(location);
            this.getData();
        }
    });
}

// 文章页
function article_page() {
    new Vue({
        el: "#article_page",
        data() {
            return {

            }
        },
        methods: {
            getData() {

            }
        },
        created() {
            this.getData();
        }
    });
}

//企业入驻_审核进度
function company_entry_review() {
    let mockData = Mock.mock({});
    pinpai_entry_review = new Vue({
        el: "#company_entry_review",
        data() {
            return {
                step: 2, //进度
                company:{}
            }
        },
        methods: {
            getData() {
                // this.quan = mockData.quan;
                let that=this;
                axios.get(urlParam.domain()+"/api/company/company/getCompanyByUserIdPC",{
                    params:{
                        token:urlParam.token()
                    }
                }).then(function (response) {
                    that.company=response.data.data;
                    if(that.company.status==0){
                        that.step=2
                    }else{
                        that.step=3
                    }
                })
            },
            //点击返回
            clickBack() {
                history.back();
            },
            //
            goentry(id) {
                window.location.href=urlParam.location()+"/index/company_entry.html?id="+id;
            }
        },
        created() {
            this.getData();
        },
        mounted() {

        },
        components: {}
    });
}